home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 138 / 138.xpi / chrome / stumbleupon.jar / content / moreChannelsDialog.js < prev    next >
Text File  |  2009-05-22  |  2KB  |  80 lines

  1. var su_ds;
  2. var channels;
  3. var channel_count;
  4.  
  5. function su_get_element(id)
  6. {
  7.     return document.getElementById(id);
  8. }
  9.  
  10. function init()
  11. {
  12.     su_ds = opener.su_ds;
  13.     var su_host = opener.parent_window.su_host;
  14.     channels = su_ds.getThruDomainChannels(true);
  15.     if (! channels)
  16.         channels = new Array();
  17.     
  18.     channel_count = channels.length;
  19.     var col_count = 1;
  20.     if (channel_count > 8)
  21.         col_count = 2;
  22.     else if (channel_count > 32)
  23.         col_count = 3;
  24.     
  25.     var row_count = Math.round(channel_count / col_count);
  26.     
  27.     var columns = su_get_element("columns");
  28.     var rows = su_get_element("rows");
  29.  
  30.     var el;
  31.     
  32.     for (i = 0; i < col_count; i++)
  33.     {
  34.         el = document.createElement("column");
  35.         columns.appendChild(el);
  36.     }
  37.     
  38.     for (i = 0; i < row_count; i++)
  39.     {
  40.         el = document.createElement("row");
  41.         el.setAttribute("id", "row_" + i);
  42.         rows.appendChild(el);
  43.     }
  44.     
  45.     for (i = 0; i < channel_count; i++)
  46.     {
  47.         el = document.createElement("checkbox");
  48.         el.setAttribute("id", "item_" + i);
  49.         el.setAttribute("label", channels[i].name);
  50.         var filename = channels[i].domain.replace(/\./g, "_") + ".ico";
  51.         el.setAttribute("src", 
  52.                     su_ds.getResourceURLFromName("favicons", filename));
  53.         if (su_host.mac || su_host.win)
  54.             el.setAttribute("class", "su-iconic-favicon");
  55.         else
  56.             el.setAttribute("class", "su-iconic-favicon-alt");
  57.         var row_el = su_get_element("row_" + (i % row_count));
  58.         row_el.appendChild(el);
  59.         el.checked = channels[i].show;
  60.     }
  61. }
  62.  
  63. function handle_accept()
  64. {
  65.     var i;
  66.     var el;
  67.     for (i = 0; i < channel_count; i++)
  68.     {
  69.         el = su_get_element("item_" + i);
  70.         channels[i].show = el.checked;
  71.         su_ds.updateRow(channels[i]);
  72.     }
  73. }
  74.  
  75. function handle_cancel()
  76. {
  77.     return true;
  78. }
  79.  
  80.